home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 1
/
Precision Software Applications Silver Collection Volume One (PSM) (1993).iso
/
children
/
fdplot13.exe
/
STAT.BAS
< prev
next >
Wrap
BASIC Source File
|
1992-01-02
|
2KB
|
59 lines
100 'Abri Technologies, Inc., Cacapon, WV 25422 - LR/Stat program - (C) 1991.
130 'X-Y stat program. Finds mean, SD, and least squares line fit
140 'for a set of data.
150 DIM DATX(100),DATY(100)
160 'print title, enter data sets
170 PRINT "X-Y data set least squares fit - paired sample statistics."
300 PRINT:PRINT
310 PRINT" Enter data-set in pairs of numbers, X,Y."
320 PRINT" Signal end of data with @,@ entry.":PRINT
330 A$=" ":B$=" ":J=0
340 WHILE A$<>"@"
350 J=J+1
360 PRINT " X";RIGHT$(STR$(J),1);",";"Y";RIGHT$(STR$(J),1);" ";
370 INPUT A$,B$
380 IF A$="@" THEN 400
390 DATX(J)=VAL(A$):DATY(J) =VAL(B$)
400 WEND
410 DTSN=J-1
420 IF J=0 THEN CHAIN "MENU"
440 REM End data def/entry
450 'Begin stat calcs.
455 MIN=1E+38:MAX=1E-38
460 FOR J=1 TO DTSN
465 IF DATX(J)<MIN THEN MIN=DATX(J)
466 IF DATX(J)>MAX THEN MAX=DATX(J)
470 XB=XB+DATX(J):YB=YB+DATY(J)
480 X2B=X2B+DATX(J)^2:Y2B=Y2B+DATY(J)^2
490 XYB=XYB+DATX(J)*DATY(J)
500 NEXT J
510 XB=XB/DTSN:YB=YB/DTSN
520 X2B=X2B/DTSN:Y2B=Y2B/DTSN
530 XYB=XYB/DTSN
540 SDX=SQR(X2B-XB*XB)
550 SDY=SQR(Y2B-YB*YB)
555 CF=SQR(DTSN/(DTSN-1.)):SDX1=SDX*CF:SDY1=SDY*CF'<-SD N-1
557 VARX=SDX1^2:VARY=SDY1^2
558 M=(XYB-XB*YB)/SDX^2
560 B=YB-M*XB
565 CORL=M*SDX/SDY
570 COV=CORL*SDX1*SDY1
640 '
690 PRINT : PRINT : ' Print stat. results.
695 PRINT" Mean SD Variance"
696 PRINT" ┌─────────────────────────────────────────────┐"
700 PRINT TAB(5)"X: │";TAB(11)XB;TAB(26)SDX1;TAB(41)VARX;TAB(54)"│"
705 PRINT TAB(5)"Y: │";TAB(11)YB;TAB(26)SDY1;TAB(41)VARY;TAB(54)"│"
706 PRINT" └─────────────────────────────────────────────┘"
710 PRINT TAB(12)"Covariance:";TAB(37)COV
715 PRINT TAB(12)"Correlation:";TAB(37)CORL
718 PRINT TAB(12)"Lin. Reg. slope:";TAB(37)M
720 PRINT TAB(12)"Lin. Reg. intercept:";TAB(37)B
750 PRINT:PRINT
760 INPUT" Press ─┘ for MENU";C$
770 CHAIN "MENU"
795 END
8000 A$=INKEY$:IF (A$="") GOTO 8000
8010 IF (ASC(A$)> 96) THEN A$=CHR$(ASC(A$)-32)
8020 PRINT A$: RETURN